/**
 * 药匙
 */
Spoon = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_SPOON);
	},
	init:function(){
		var spoon = new Button(this, 8, TAG_SPOON_SPOON, "#spoon5.png", this.callback);
		spoon.setRotation(120);
		if(gg.flow.flow.action==ACTION_DO1){
			var mov1=cc.moveTo(0.6, cc.p(15,-18));
			var mov2=cc.moveTo(0.6, cc.p(0,0));
			var seq=cc.sequence(cc.delayTime(0.8),cc.callFunc(function() {
				this.absorbBack();
			}, this),mov1,mov2,mov1,cc.callFunc(function() {
				var magnet=this.getParent().getChildByTag(TAG_MAGNET);
				magnet.removeFromParent();
				this.removeFromParent();
				gg.flow.next();
			}, this));
			spoon.runAction(seq);
		}else{
			var mov1=cc.moveTo(0.6, cc.p(100,-136));
			var mov2=cc.moveTo(0.6, cc.p(130,-178));			
			var seq=cc.sequence(mov1,mov2,mov1,mov2,mov1,mov2,cc.callFunc(function() {
				this.removeFromParent();
				gg.flow.next();
			}, this));
			spoon.runAction(seq);
			
			var filter=ll.run.getChildByTag(TAG_PAPER).getChildByTag(TAG_FILTER);
			var mov=cc.moveTo(0.6, cc.p(94,-109));
			var rot=cc.rotateTo(0.6, 40);
			var seq=cc.sequence(mov,rot,cc.delayTime(0.8),cc.callFunc(function() {
				var fe=filter.getChildByTag(TAG_FILTER_FE);
				var s=filter.getChildByTag(TAG_FILTER_S);
				var moveto=cc.moveTo(1, cc.p(108,27));
				var rotate=cc.rotateTo(1, -35);
				var scale=cc.scaleTo(1,2,0.2 );
				var spawn1=cc.spawn(moveto,rotate,scale);
				var spawn2=spawn1.clone();				
				var seq1=cc.sequence(spawn1,cc.callFunc(function() {
					var slot=ll.run.getChildByTag(TAG_PAPERSLOT).getChildByTag(TAG_SLOT);
					fe.removeFromParent();
					fe.setPosition(cc.p(35,11));
					fe.setRotation(0);
					slot.addChild(fe);
				}, this));
				fe.runAction(seq1);
				var seq2=cc.sequence(spawn2,cc.callFunc(function() {
					var slot=ll.run.getChildByTag(TAG_PAPERSLOT).getChildByTag(TAG_SLOT);
					s.removeFromParent();					
					s.setPosition(cc.p(35,11));
					s.setRotation(0);
					slot.addChild(s);
				}, this));
				s.runAction(seq2);
			}, this),cc.delayTime(1.5),cc.callFunc(function() {
				ll.run.getChildByTag(TAG_PAPER).removeFromParent();
			}, this));
			filter.runAction(seq);
		}

		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
	},
	absorbBack:function(){
		var fe=this.getParent().getChildByTag(TAG_PAPER).getChildByTag(TAG_FILTER).getChildByTag(TAG_FILTER_FE);
		var mov=cc.moveTo(0.8, cc.p(45,30));
		var rot=cc.rotateTo(0.8, 0);
		var sca=cc.scaleTo(0.8, 2, 1);
		var spa=cc.spawn(mov,rot,sca);
		var seq=cc.sequence(cc.delayTime(0.5),spa);
		fe.runAction(seq);
	},
	callback:function(p){
		switch(p.getTag()){
		case TAG_SPOON_SPOON:

			break;
		}
	},
	actionDone:function(p){
		switch(p.getTag()){
		case TAG_SPOON_SPOON:
			break;
		}
	},
	onExit:function(){
		this._super();
		this.callNext.release();
	}
});